<?php
/**
 * Number 处理与数字相关的类库方法
 */
declare(strict_types=1);

namespace app\common\lib;

class Number
{
    /**
     * 生成验证码
     *
     * @param int $length
     * @return int
     */
    public static function getCode(int $length = 6):int
    {
        $code = rand(100000, 999999);
        if ($length == 4) {
            $code = rand(1000, 9999);
        }
        return $code;
    }
}